# @author Cweili
# @version 13-9-15 下午14:52

updateList = null

delCustomer = (ids) ->
	$.post 'ip/adminDel', 'ids=' + ids, (data) ->
		updateList()

$ ->

	updateList = ->
		list 'ip/list', '', '#list', (item) ->
			item.customerName = if item.customer? then item.customer.name else '无'
			item.ipGroupName = item.ipGroup.name
			item.commentStr = if item.comment? && item.comment != '' then item.comment else item.ipGroup.comment
			item.startTimeStr = if item.startTime then item.starTime.format() else ''
			item.operatorTemplate = operatorTemplate(item.id)
			render('listTpl', item)

	$('#editorModal').find('form').submit (e) ->
		e.preventDefault()
		save 'ip/adminSave', (data) ->
			saveAction(data, updateList)

	updateList()

	radio 'ipgroup/list', '', 'ipGroup', (item) ->
		render('ipGroupBtnTpl', item)
